import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../utils/util.dart';

//返回null 未弹起  true 点击确定
Future<bool?> showRemindAlert({
  final String? title,
  final String? msg,
  final String? sureText,
  final Color? cancelColor,
  final Color? sureColor,
  final VoidCallback? cancelAction,
  final VoidCallback? sureAction,
}) {
  if (Get.context == null) {
    return Future.value(null);
  }
  if (!isNilStr(title) && !isNilStr(msg)) {
    if (SpUtil().getBool(title ?? msg!) == true) {
      return Future.value(null);
    }
  }
  var isSelected = false;
  return showCupertinoDialog<bool>(
      context: Get.context!,
      barrierDismissible: false,
      builder: (context) {
        return AlertDialog(
          backgroundColor: Colors.white,
          surfaceTintColor: Colors.white,
          contentPadding:
              EdgeInsets.symmetric(horizontal: 20.r, vertical: 15.r),
          title: title == null
              ? null
              : Text(
                  title,
                  style: TextStyle(
                      color: const Color(0xff333333),
                      fontSize: 18.sp,
                      fontWeight: FontWeight.bold),
                ),
          content: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (msg != null)
                Text(
                  msg,
                  textAlign: TextAlign.left,
                  style: TextStyle(
                      color: const Color(0xff666666), fontSize: 15.sp),
                ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  RadioItem(
                    text: Ls.noRemind,
                    value: 1,
                    isCircle: false,
                    iconSize: 25.r,
                    onTap: (p0) {
                      isSelected = p0;
                    },
                  ),
                  TextButton(
                      onPressed: () {
                        SpUtil().setBool(title ?? msg!, isSelected);
                        Get.back(result: true);
                      },
                      child: Text(
                        sureText ?? Ls.ok,
                        style: const TextStyle(color: Colors.red),
                      )),
                ],
              )
            ],
          ),
        );
      });
}
